<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\UserAuth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class VerificationController extends ApiBaseController
{
    public function index(Request $request, UserAuth $model)
    {
        $data = [];
        $data['uid'] = $this->getUid($request);
        $result = $model->index($data);
        return $this->success($result);
    }

    public function request(Request $request, UserAuth $model)
    {
        $data = $request->all();
        if ($r = $this->verifyField($data, [
            "realname" => "bail|required|min:3|max:32",
            "id_card" => "bail|required|alpha_num|min:10|max:64",
            "front_img" => "bail|required|min:10|max:64",
            "back_img" => "bail|required|min:10|max:64",
        ])) {
            return $r;
        }
        $data['uid'] = $this->getUid($request);
        $result = $model->request($data);
        return $this->success($result);
    }
}
